﻿using System.Collections.Generic;
using Zavand.Web.Mvc.Manana.Framework;
using Zavand.Web.Mvc.Manana.SampleWebsite.Common;

namespace Zavand.Web.Mvc.Manana.SampleWebsite.Areas.Area1.Controllers.Default.Actions.Index
{
    public class Model : DefaultControllerModel<Route, DefaultController>, IPageable
    {
        public List<User> Users { get; set; }
        public int Page { get; set; }
        public int PageSize { get; set; }

        public int Total { get; set; }
        public int TotalPages
        {
            get { return Total / PageSize + ((Total % PageSize) > 0 ? 1 : 0); }
        }

        public override void SetupModel(DefaultController controller, Route route)
        {
            base.SetupModel(controller, route);
            Page = route.Page.Value;
            PageSize = route.PageSize.Value;
        }
    }
}